package com.lynx.system.service;

import com.lynx.system.beans.Order;
import com.lynx.system.repository.OrderRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


import java.util.Date;
import java.util.List;

@Service
public class OrderServiceImpl implements OrderService {
    @Autowired
    private OrderRepository orderRepository;
    @Override
    public void save(Order order) {
        order.setDate(new Date());
        orderRepository.insertOrder(order);
    }

    @Override
    public List<Order> findOrdersByUid(long uid,int index, int limit) {
        return orderRepository.selectOrdersByUid(uid, index, limit);
    }

    @Override
    public int findCountByUid(long uid) {
        return orderRepository.selectCountByUid(uid);
    }

    @Override
    public List<Order> findOrdersByState(int state,int index,int limit) {
        return orderRepository.selectOrdersByState(state,index,limit);
    }

    @Override
    public int findCountByState(int state) {
        return orderRepository.selectCountByState(state);
    }

    @Override
    public void editState(long id) {
        orderRepository.updateState(id);
    }
}
